Skip to content

Conversation

@olljanat
Copy link
Contributor

Description

Revisit logic added by #25533 and make sure that it does not break Windows compatibility.

Without this volume creation targeting to Windows node failed to error:

Error creating volume: Unexpected response code:
 500 (rpc error: rpc error: HostVolume.Create error:
 error changing owner/group:
 chown c:\opt\nomad\data\host_volumes\688372d2-c709-de26-5718-effd054bb95a: not supported by windows)

Testing & Reproduction steps

name = "example"
node_id  = "<node id>"
type = "host"
plugin_id = "mkdir"
capability {
  access_mode  = "single-node-single-writer"
  attachment_mode = "file-system"
}

nomad volume create volume.hcl

Links

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad product documentation, which is stored in the
    web-unified-docs repo. Refer to the web-unified-docs contributor guide for docs guidelines.
    Please also consider whether the change requires notes within the upgrade
    guide
    . If you would like help with the docs, tag the nomad-docs team in this PR.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

@olljanat olljanat force-pushed the fix-win-dynamic-host-volume branch from 5282e74 to de3b143 Compare December 2, 2025 14:43
@olljanat
Copy link
Contributor Author

olljanat commented Dec 2, 2025

Rebased just in case.

@tgross PTAL

if err := os.RemoveAll(path); err != nil {
log.Error("failed to remove directory after create failure",
"error", err)
if params.Uid != -1 || params.Gid != -1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If os.Chown always returns an error on windows, should we just wrap the chown in a if runtime.GOOS != "windows"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would works too but isn't that bad that user might expect to set permissions which is not actually done?

Based on code -1 means change nothing so current logic would works exactly same way in both Linux and Windows as long user do not configure permissions but any other value would still give error not supported by windows

Copy link
Member

@mismithhisler mismithhisler Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Also, I apologize for belaboring this, but I was curious how this was handled elsewhere in the codebase (it's not the only place we use os.Chown(). It looks we only chown when the euid from syscall.Geteuid() is 0. I wonder if, for consistency sake, we should do something similar here? This syscall returns -1 on Windows. See here for reference.

Either way, I think it's probably useful for someone on the Nomad team (I can do this) to update the mkdir plugin docs to let Windows users know that ownership changing is not available on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants